/*
 * searchTableModel.java
 *
 * Created on June 27, 2005, 3:36 PM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package com.bff.slimserver.musicjukebox.lib;

import com.bff.bjj.utils.Resources.LABEL_KEY;
import org.bff.slimserver.musicobjects.SlimSong;

/**
 *
 * @author Bill
 */
public class SearchTableModel extends SongTableModel {
    
    public static final int ARTIST = 0;
    public static final int ALBUM = 1;
    public static final int TITLE = 2;
    public static final int LENGTH = 3;
    public static final int TRACK = 4;
    public static final int YEAR = 5;
    public static final int BITRATE = 6;

    public final static String[] columnNames = {
        getHeader(LABEL_KEY.HEADER_ARTIST),
        getHeader(LABEL_KEY.HEADER_ALBUM),
        getHeader(LABEL_KEY.HEADER_TITLE),
        getHeader(LABEL_KEY.HEADER_LENGTH),
        getHeader(LABEL_KEY.HEADER_TRACK),
        getHeader(LABEL_KEY.HEADER_YEAR),
        getHeader(LABEL_KEY.HEADER_BITRATE)
    };

    public SearchTableModel(java.util.Collection songs) {      
        super(songs);
    }
    
    @Override
    public int getRowCount() {
        return(dataList.size());
    }
    
    @Override
    public Object getValueAt(int row, int col) {
        SlimSong song = (SlimSong)dataList.get(row);
        switch (col) {
            case ARTIST:
                return(song.getArtist());
            case ALBUM:
                return(song.getAlbum().getName());
            case TITLE:
                return(song.getTitle());
            case LENGTH:
                return(song.getLength());
            case TRACK:
                return(song.getTrack());
            case YEAR:
                return(song.getYear());
            case BITRATE:
                return(song.getBitrate());
            default:
                return null;
        }
    }
    
    @Override
    public int getColumnCount() {
        return(columnNames.length);
    }
    
    @Override
    public String getColumnName(int column) {
        return columnNames[column];
    }

    @Override
    public int getArtistColumnIndex() {
        return(ARTIST);
    }
    
    @Override
    public int getAlbumColumnIndex() {
        return(ALBUM);
    }
    
    @Override
    public int getTitleColumnIndex() {
        return(TITLE);
    }
    
    @Override
    public int getLengthColumnIndex() {
        return(LENGTH);
    }
    
    @Override
    public int getTrackColumnIndex() {
       return(TRACK);
    }
    
    @Override
    public int getYearColumnIndex() {
        return(YEAR);
    }

    @Override
    public int getBitrateColumnIndex() {
         return(BITRATE);
    }

    @Override
    public int getSortColumn() {
        return getTitleColumnIndex();
    }

}